import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SliverFansDelegate extends SliverPersistentHeaderDelegate {
  final Color backgroundColor;
  final TabBar tabBar;
  final Widget search;
  final bool isEmpty;

  const SliverFansDelegate(
      {required this.tabBar,
      required this.search,
        required this.backgroundColor,required this.isEmpty});

  @override
  double get minExtent => tabBar.preferredSize.height;

  @override
  double get maxExtent => tabBar.preferredSize.height + 56.w;

  @override
  Widget build(context, shrinkOffset, overlapsContent) {
    return Container(
      color: Colors.transparent,
      width: double.infinity,
      margin: EdgeInsets.only(left: 0.w,right: 0.w),
      height: maxExtent,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start ,
        children: [
          Stack(
            children: [
              Positioned(
                child: Container(
                color: Color.fromRGBO(243, 242, 247, 1) ,
                height: 1.w,
                width: double.infinity,
              ),bottom: 1.w,
                left: 0,
                right: 0,
              ),
              Container(
                width: double.infinity,
                padding: EdgeInsets.only(left: 20.w,right: 20.w)
                ,child: tabBar,),
            ],
          ),
          search
        ],
      ),
    );
  }

  @override
  bool shouldRebuild(SliverFansDelegate oldDelegate) {
    return tabBar != oldDelegate.tabBar;
  }
}
